const multer  = require('multer')
const storage = multer.diskStorage({
    // 加一个拦截器
    destination: function (req, file, cb) {
      cb(null, './public/uploads')
    },
    filename: function (req, file, cb) {
      console.log(file)
      const extNameArr = file.originalname.split('.');
    
      const ext = extNameArr[extNameArr.length-1];
      console.log(ext)
      cb(null, file.fieldname + '-' + Date.now()+'.'+ext);
    }
  })
   
const upload = multer({ storage: storage })

module.exports = upload